package com.iqiyi.pps.epg.core.model.auth;

import com.iqiyi.pps.epg.core.model.base.BaseEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;

/**
 * 权限.
 * 
 */
@Entity
@Table(name = "show_auth_authority")
@Cache(usage = CacheConcurrencyStrategy.NONE)
public class Authority extends BaseEntity {

	/**
	 * SpringSecurity中默认的角色/授权名前缀.
	 */
    private static final long serialVersionUID = -5609940996736989785L;
	public static final String AUTHORITY_PREFIX = "AUTH_";
    public static final String AUTHORITY_ALL = "AUTH_ALL";
    private String name;

    private String description;

    private Boolean enabled = false;
    protected Long id;


	public void setId(Long id) {
		this.id = id;
	}
    @Override
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }
	public Authority() {
	}

	public Authority(Long id, String name) {
		this.id = id;
		this.name = name;
	}

	@Column(nullable = false, unique = true)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    @Transient
	public String getPrefixedName() {
		return AUTHORITY_PREFIX + name;
	}
}
